package com.weixin.paleituo.adapter;

import android.support.v4.view.PagerAdapter;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * 共享家样板间
 *
 * @author fengzhen
 * @version v1.0, 2018/4/16
 */
public class SharedHousePagerAdapter extends PagerAdapter {
    private List<View> mRecyclerList;

    public SharedHousePagerAdapter(List<View> recyclerList) {
        super();
        this.mRecyclerList = recyclerList;
    }

    @Override
    public int getCount() {
        return mRecyclerList == null ? 0 : mRecyclerList.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View child = mRecyclerList.get(position);
        container.addView(child);
        return child;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
//        container.removeView(mRecyclerList.get(position));
        container.removeView((View) object);
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }
}
